import axios from '@/libs/api.request'

/**
 * 通用Ajax请求
 * @returns {RequestTask | never}
 */
const easy_ajax = (options) => {
  if (!options.url || options.url === '') {
    return false
  }
  let method = 'get'
  if (options.method) {
    method = options.method
  }
  let params = {}
  let data = options.data
  if (method === 'get') {
    params = data
    data = {}
  }
  return axios.request({
    url: options.url,
    method: method,
    params: params,
    data: data
  })
}

export default easy_ajax
